package com.vehicle.auto.click.business;

import com.vehicle.auto.click.common.ApplicationContextProvider;
import com.vehicle.auto.click.common.UiJTextArea;
import com.vehicle.auto.click.enums.DataBaseVserionEnum;
import com.vehicle.auto.click.model.UiVehicleInfo;
import com.vehicle.auto.click.model.VehicleInfo;
import java.awt.Container;
import java.awt.LayoutManager;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.List;
import javax.swing.ButtonGroup;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.SwingWorker;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.ibatis.javassist.compiler.TokenId;
import org.thymeleaf.standard.processor.StandardAttrTagProcessor;
import org.thymeleaf.standard.processor.StandardWithTagProcessor;

/* loaded from: vehicle2.jar:BOOT-INF/classes/com/vehicle/auto/click/business/UIFrame.class */
public class UIFrame extends JFrame {
    private SwingWorker w;

    public UIFrame(String title) {
        super(title);
        this.w = null;
        Container panel = getContentPane();
        panel.setLayout((LayoutManager) null);
        JTextArea textArea = UiJTextArea.getUiJTextArea();
        textArea.setText("欢迎使用自动审核工具！\r\n power by 泓胜科技股份有限公司");
        JScrollPane jsp = new JScrollPane(textArea);
        jsp.setBounds(5, 5, 300, (int) StandardWithTagProcessor.PRECEDENCE);
        jsp.setVerticalScrollBarPolicy(22);
        panel.add(jsp);
        ImageIcon imageIcon = new ImageIcon("config/logoA.jpg");
        JLabel logo = new JLabel(imageIcon);
        logo.setBounds(390, 20, 200, 200);
        panel.add(logo);
        JLabel database = new JLabel("数据库版本：");
        database.setBounds((int) TokenId.ARSHIFT, 300, 80, 25);
        panel.add(database);
        JRadioButton newRadioButton = new JRadioButton("新");
        newRadioButton.setBounds(450, 300, 50, 25);
        newRadioButton.setActionCommand(DataBaseVserionEnum.new_database_version.getCode());
        newRadioButton.setSelected(true);
        panel.add(newRadioButton);
        JRadioButton oldRadioButton = new JRadioButton("旧");
        oldRadioButton.setBounds(520, 300, 50, 25);
        oldRadioButton.setActionCommand(DataBaseVserionEnum.old_database_version.getCode());
        panel.add(oldRadioButton);
        final ButtonGroup bGroup = new ButtonGroup();
        bGroup.add(newRadioButton);
        bGroup.add(oldRadioButton);
        JButton startButton = new JButton("开始自动点击");
        startButton.setBounds(412, 400, 165, 25);
        panel.add(startButton);
        JPanel jPanel_time = new JPanel();
        jPanel_time.setBounds((int) StandardAttrTagProcessor.PRECEDENCE, 0, 400, 35);
        JLabel label_time = new JLabel("开始时间(如2020-01-01)：");
        jPanel_time.add(label_time);
        final JTextField jtf_time = new JTextField(7);
        jPanel_time.add(jtf_time);
        JLabel label_time_end = new JLabel("结束时间：");
        jPanel_time.add(label_time_end);
        final JTextField jtf_time_end = new JTextField(7);
        jPanel_time.add(jtf_time_end);
        panel.add(jPanel_time);
        JPanel jPanel = new JPanel();
        jPanel.setBounds((int) StandardAttrTagProcessor.PRECEDENCE, 40, 400, 35);
        JLabel label = new JLabel("请输入车牌号,车牌号注意去掉省份：");
        jPanel.add(label);
        final JTextField jtf = new JTextField(10);
        jPanel.add(jtf);
        JButton jButton = new JButton("查询");
        jPanel.add(jButton);
        panel.add(jPanel);
        final JTextArea jTextArea = new JTextArea();
        jTextArea.setText("查询UI自动点击车辆总数及详情,车牌号不填默认查询全部车辆！\r\n注意勾选数据库对应版本，默认数据库版本新5.0!!\r\n\r\n");
        JScrollPane jsp1 = new JScrollPane(jTextArea);
        jsp1.setBounds((int) StandardAttrTagProcessor.PRECEDENCE, 80, 400, 550);
        jsp1.setVerticalScrollBarPolicy(22);
        panel.add(jsp1);
        startButton.addActionListener(new ActionListener() { // from class: com.vehicle.auto.click.business.UIFrame.1
            public void actionPerformed(ActionEvent e) {
                UIFrame.this.w = new SwingWorker() { // from class: com.vehicle.auto.click.business.UIFrame.1.1
                    protected Object doInBackground() throws Exception {
                        synchronized (this) {
                            System.out.println("开始按钮被点击");
                            UIFrameService uiFrameService = (UIFrameService) ApplicationContextProvider.getBean(UIFrameService.class);

                            uiFrameService.startButton(bGroup.getSelection().getActionCommand());
                        }
                        return null;
                    }
                };
                UIFrame.this.w.execute();
            }
        });
        jButton.addActionListener(new ActionListener() { // from class: com.vehicle.auto.click.business.UIFrame.2
            public void actionPerformed(ActionEvent e) {
                jTextArea.setText("查询UI自动点击车辆总数及详情,车牌号不填默认查询全部车辆！\r\n注意勾选数据库对应版本，默认数据库版本新5.0!!\r\n\r\n");
                System.out.println("查询按钮被点击");
                String hphm = jtf.getText();
                String time_start = jtf_time.getText();
                String time_end = jtf_time_end.getText();
                System.out.println("输入的车牌号" + hphm);
                UIFrameService uiFrameService = (UIFrameService) ApplicationContextProvider.getBean(UIFrameService.class);
                UiVehicleInfo uiVehicleInfo = uiFrameService.selectVehicle(bGroup.getSelection().getActionCommand(), hphm, time_start, time_end);
                jTextArea.append("UI审核车辆点击通过总数：" + uiVehicleInfo.getPassNum() + "辆\r\n");
                jTextArea.append("UI审核车辆点击不通过总数：" + uiVehicleInfo.getNoPassNum() + "辆\r\n\r\n");
                List<VehicleInfo> vehicleInfos = uiVehicleInfo.getList();
                if (CollectionUtils.isNotEmpty(vehicleInfos)) {
                    for (VehicleInfo vechicle : vehicleInfos) {
                        if (vechicle.getIs_pass().toString().equals("1")) {
                            jTextArea.append(vechicle.getCopy_text() + "点击通过\r\n");
                        } else {
                            jTextArea.append(vechicle.getCopy_text() + "点击不通过\r\n");
                        }
                    }
                }
            }
        });
    }
}